package org.ym.file.domain.model.node.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 节点类型 LOCAL,IPV4,IPV6
 *
 * @author ym
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum NodeInfoType {
    /**
     *
     */
    LOCAL(1, "本机"), IPV4(2, "IPV4地址"), IPV6(3, "IPV6地址");
    /**
     * 代码
     */
    private final int code;
    /**
     * 名称
     */
    private final String name;

    /**
     * @param code code
     * @return NodeInfoType
     */
    public static NodeInfoType of(int code) {
        switch (code) {
            case 1:
                return LOCAL;
            case 2:
                return IPV4;
            case 3:
                return IPV6;
        }
        return null;
    }
}
